﻿
@{
    Layout = null;
}

<div>
    <div class="input-group">
        <div class="col-3 pr-0" style="display: none">@* 该页面适用于所有的审批 *@
            <label id="EAA-DomainName">@ViewData["DomainName"]</label>
            <label id="EAA-DomainId">@ViewData["DomainId"]</label>
            <label id="EAA-UserName">@ViewData["UserName"]</label>
            <label id="EAA-UserId">@ViewData["UserId"]</label>
            <label id="EAA-Parent-ModalID">@ViewData["ModalID"]</label>
            <label id="EAA-DisplayUser">@ViewData["DisplayUser"]</label>
        </div>
    </div>
    <div class="input-group" id="EAA-divGroup">
        <div class="col-4 pr-0">
            <span class="input-group-text font-rfs border-radius-noright noRightBorder">实验室及组</span>
        </div>
        <div class="col-8 pl-0 input-group">
            <select id="EAA-Site" class="form-control font-rfs border-radius-noleft" style="width:50%"></select>
            <select id="EAA-Group" class="form-control font-rfs border-radius-noleft" style="width:50%"></select>
        </div>
    </div>
    <div class="input-group" id="EAA-divUser">
        <div class="col-4 pr-0">
            <span class="input-group-text font-rfs border-radius-noright noRightBorder">下一步审批人*</span>
        </div>
        <div class="col-8 pl-0 input-group">
            <select id="EAA-User" class="form-control font-rfs border-radius-noleft" style="width:90%"></select>
        </div>
    </div>
    <div class="input-group">
        <div class="col-4 pr-0">
            <span class="input-group-text font-rfs border-radius-noright noRightBorder">处理意见</span>
        </div>
        <div class="col-8 pl-0">
            <input id="EAA-Suggestion" class="form-control font-rfs border-radius-noleft" placeholder="可选" />
        </div>
    </div>
    <br />
    <div class="text-right">
        <button id="EAA-confirm" class="btn btn-primary font-rfs">同意</button>
        <button id="EAA-cancel" type="button" class="btn btn-info font-rfs">取消</button>
    </div>
</div>

<script>

    $(document).ready(function () {
        if ($("#EAA-DisplayUser").html() == "True") {
            LoadSiteList("EAA-Site");
            LoadUsers("EAA-User");
        } else {
            $("#EAA-divGroup").css('display', 'none');
            $("#EAA-divUser").css('display', 'none');
        }
    });

    $("#EAA-Site").change(function () {
        LoadGroupList($("#EAA-Site").find("option:selected").text(), "EAA-Group");
    });

    $("#EAA-Group").change(function () {
        LoadGroupUsers("EAA-User", $("#EAA-Group").find("option:selected").val());
    });

    $("#EAA-confirm").click(function () {
        if ($("#EAA-DisplayUser").html() == "True") {
            if ($("#EAA-User").val().length == 0) {
                alert("必需选择一个审批人！");
                $("#EAA-User").addClass('error-style');
                return false;
            }
        }

        $.post("/WorkFlow/Continue", {
            DomainName: $("#EAA-DomainName").html(),
            DomainId: $("#EAA-DomainId").html(),
            NextUserId: $("#EAA-User").find("option:selected").val(),
            Suggestion: $.trim($("#EAA-Suggestion").val())
        }, function (data) {
            alert(data);
            $("#EAA-cancel").click();
        });

    });

    $("#EAA-cancel").click(function () {
        var modalID = $("#EAA-Parent-ModalID").html();
        $("#" + modalID).modal('hide');
    });
    
</script>
